﻿<Window x:Class="DataBinding.VariedStyles"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="VariedStyles" Height="420" Width="675" 
    xmlns:local="clr-namespace:DataBinding"
    >
    <Window.Resources>
        <Style x:Key="DefaultStyle" TargetType="{x:Type ListBoxItem}">
            <Setter Property="Background" Value="LightYellow" />
            <Setter Property="Padding" Value="2" />
        </Style>

        <Style x:Key="HighlightStyle" TargetType="{x:Type ListBoxItem}">
            <Setter Property="Background" Value="LightSteelBlue" />
            <Setter Property="FontWeight" Value="Bold" />
            <Setter Property="Padding" Value="2" />
        </Style>
    </Window.Resources>
  
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="3*"></ColumnDefinition>
      <ColumnDefinition Width="5*"></ColumnDefinition>
    </Grid.ColumnDefinitions>

    <Grid>
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"></RowDefinition>
        <RowDefinition Height="*"></RowDefinition>
        <RowDefinition Height="Auto"></RowDefinition>
      </Grid.RowDefinitions>

      <Button Margin="7,7,7,0" Padding="2" Click="cmdGetProducts_Click">Get Products</Button>      
      
      <ListBox Grid.Row="1" Margin="7,3,7,10" Name="lstProducts" HorizontalContentAlignment="Stretch"
              SnapsToDevicePixels="True"  >
        <ListBox.ItemContainerStyleSelector>
          <local:SingleCriteriaHighlightStyleSelector
            DefaultStyle="{StaticResource DefaultStyle}"
            HighlightStyle="{StaticResource HighlightStyle}"
            PropertyToEvaluate="CategoryName"
            PropertyValueToHighlight="Travel"
            >         
          </local:SingleCriteriaHighlightStyleSelector>
        </ListBox.ItemContainerStyleSelector>        
      </ListBox>

      <Button Margin="7,0,7,7" Grid.Row="3" Padding="2" Click="cmdApplyChange_Click">Change One Item</Button>
    </Grid>

    <GridSplitter Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Stretch"
                   Width="5"></GridSplitter>

    <Border Grid.Column="1" Padding="7" Margin="7" Background="LightSteelBlue">
      <Grid DataContext="{Binding ElementName=lstProducts, Path=SelectedItem}" >
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto"></ColumnDefinition>
          <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto"></RowDefinition>
          <RowDefinition Height="Auto"></RowDefinition>
          <RowDefinition Height="Auto"></RowDefinition>
          <RowDefinition Height="Auto"></RowDefinition>
          <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        
        <TextBlock Margin="7">Model Number:</TextBlock>
        <TextBox Margin="5" Grid.Column="1" Text="{Binding Path=ModelNumber}"></TextBox>
        <TextBlock Margin="7" Grid.Row="1">Model Name:</TextBlock>
        <TextBox Margin="5" Grid.Row="1" Grid.Column="1" Text="{Binding Path=ModelName}"></TextBox>
        <TextBlock Margin="7" Grid.Row="2">Unit Cost:</TextBlock>
        <TextBox Margin="5" Grid.Row="2" Grid.Column="1" Text="{Binding Path=UnitCost}"></TextBox>
        <TextBlock Margin="7,7,7,0" Grid.Row="3">Description:</TextBlock>
        <TextBox Margin="7" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" 
                 TextWrapping="Wrap" VerticalScrollBarVisibility="Visible" Text="{Binding Path=Description}"></TextBox>

      </Grid>
    </Border>

  </Grid>
</Window>
